home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Blitz2 / BlitzFaq / FaqLists / Parseshapes.txt < prev    next >
Encoding:
Text File  |  1996-09-05  |  1.1 KB  |  61 lines

  1. DEFTYPE .w
  2.  
  3. NEWTYPE .shp
  4.   _pixwidth.w
  5.   _pixheight.w
  6.   _depth.w
  7.   _ebwidth.w
  8.   _bltsize.w
  9.   _xhandle.w
  10.   _yhandle.w
  11.   _data.l
  12.   _cookie.l
  13.   _onebpmem.w
  14.   _onebpmemx.w
  15.   _allbpmem.w
  16.   _allbpmemx.w
  17.   _pad.b[2]
  18. End NEWTYPE
  19.  
  20. InitBank 0,32,0              ;Buffer to handle shapes'structures
  21.  
  22. *shapenow.shp=Bank(0)
  23.  
  24. USEPATH *shapenow
  25. Function .w ParseShapesFile{filename$}
  26.   SHARED *shapenow.shp
  27.   If ReadFile(0,filename$)
  28.  
  29.     seekto.l=0
  30.     filelenght.l=Lof(0)
  31.     counting.w=0
  32.     forcexit=False
  33.  
  34.     Repeat
  35.       FileSeek 0,seekto
  36.       ReadMem 0,Bank(0),32
  37.       counting+1
  38.       seekto+\_allbpmem+32
  39.       If \_pixwidth>640 OR \_pixwidth<0 OR \_pixheight>512 OR \_pixheight<0 OR \_depth>8 OR \_depth<0
  40.         forcexit=True
  41.         counting=-1
  42.       EndIf
  43.     Until seekto>filelenght OR forcexit
  44.     Function Return counting
  45.   Else
  46.     Function Return -2
  47.   EndIf
  48. End Function
  49.  
  50. ; Check it!
  51. NPrint ""
  52. nrofshapes=ParseShapesFile{"ram:aaaa"}
  53. Select nrofshapes
  54. Case -1
  55.   NPrint "Not a Blitz2 shapes file."
  56. Case -2
  57.   NPrint "Can't open file."
  58. Default
  59.   NPrint "Found ",nrofshapes," shapes."
  60. End Select
  61.